package Person.Buffer;

import java.io.*;

public class CopyAviDemo {
    public static void main(String[] args) throws IOException {
        long stratTime = System.currentTimeMillis();//记录开始时间
        //复制视频
        //method01();
       // method02();
       // method03();
        method04();
        //记录结束时间
        long endTime = System.currentTimeMillis();//记录结束时间
        System.out.println(endTime-stratTime);
    }
    //字节缓冲流一次读写一个字节数组
    private static void method04() throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("C:\\Users\\win10\\IdeaProjects\\ith\\mn.jpg"));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("C:\\Users\\win10\\IdeaProjects\\IDEA\\mn.jpg"));
        byte[] bys = new byte[1024];
        int len;
        while((len=bis.read(bys))!=-1){
            bos.write(bys,0,len);
        }
bos.close();
        bis.close();



    }
    //字节缓冲流一次读写一个字节
    private static void method03() throws IOException{
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("C:\\Users\\win10\\IdeaProjects\\ith\\mn.jpg"));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("C:\\Users\\win10\\IdeaProjects\\IDEA\\mn.jpg"));
        int by;
        while((by=bis.read())!=-1){
            bos.write(by);
        }
        bos.close();
        bis.close();
    }
    //基本字节流一次读写一个字节数组
    private static void method02() throws IOException {
        FileInputStream fis = new FileInputStream("C:\\Users\\win10\\IdeaProjects\\ith\\mn.jpg");
        FileOutputStream fos = new FileOutputStream("C:\\Users\\win10\\IdeaProjects\\IDEA\\mn.jpg");
    int by;
    while((by=fis.read())!=-1){
        fos.write(by);
    }
    fos.close();
    fis.close();
    }
    //基本字节流一次读写一个字节
    private static void method01() throws IOException {
        FileInputStream fis = new FileInputStream("C:\\Users\\win10\\IdeaProjects\\ith\\mn.jpg");
        FileOutputStream fos = new FileOutputStream("C:\\Users\\win10\\IdeaProjects\\IDEA\\mn.jpg");
   byte[] bys = new byte[1024];
   int len;

   while((len=fis.read())!=-1){
       fos.write(bys,0,len);
   }
        fos.close();
        fis.close();




    }
}
